package cn.samler.shopapi.Model.Request.Cart;

import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import org.apache.commons.codec.digest.DigestUtils;

import java.util.HashMap;

@Data
public class Goods {
    private Integer gid;
    private HashMap<String, Integer> spec;
    private Integer number;

    public String getSpecToken() {
        JSONObject json = new JSONObject();
        this.spec.forEach((k, v) -> {
            json.put(k, v);
        });

        return DigestUtils.md5Hex(json.toJSONString());
    }
}
